home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / mycmm220.zip / MCHOST.SCP < prev    next >
Text File  |  1994-03-29  |  9KB  |  298 lines

  1. ; *** MCHOST.SCP ***  Example for using MyComm as a host
  2. ; Copyright 1994 Ken Dorshimer - All Rights Reserved
  3. ;
  4. ; NOTE: This is a _very_ simple host example using the
  5. ;       MyComm "script" language. MyComm is not intended
  6. ;       to be used as a full blown BBS. However by using
  7. ;       the MyComm script language functions and a little
  8. ;       imagination it is possible to create a script that
  9. ;       behaves like a simple host for transfering files.
  10. ;
  11. ;       This script is provided only as an example to
  12. ;       add a "host like" function to MyComm.
  13. ;
  14. ;       This example allows for one user-name and one
  15. ;       password. There is no provision for entering messages,
  16. ;       reading messages, or message areas.
  17. ;
  18.  
  19. IgnoreCD("Y")              ; Ignore Carrier Detect status
  20. LoclEcho("Y")              ; Turn on Host Mode
  21. :start
  22. Hangup()                   ; Make sure we're off-line
  23. Xmit("ATS0=1")             ; Tell modem to answer on one ring
  24.  
  25. :begin                     ; Waiting for a call
  26. Pause(1)
  27. If("CARDET", "gotcall")    ; When call comes in start session
  28. Goto("begin")
  29.  
  30. :gotcall
  31. Xmit("^L)                  ; Send "Form Feed" to clear screen
  32.  
  33.                            ; Send an opening screen. Note that the
  34.                            ; ASCII upload function could also be
  35.                            ; used to send a text file to the user
  36.                            ; that contains your opening screen.
  37.  
  38. Xmit("Welcome To a Very Little BBS Indeed!")
  39. Xmit("^M^J")               ; Send a blank line
  40. Xmit("1.4K bps - 8-N-1")
  41.  
  42. If("NOCARDET", "start")    ; If caller hangs up reset script
  43. GoSub("getname")           ; GoSub to the user name routine
  44. If("NOCARDET", "start")    ; If caller hangs up reset script
  45. GoSub("getpass")           ; GoSub to the user password routine
  46. If("NOCARDET", "start")    ; If caller hangs up reset script
  47.  
  48.                            ; OK so far let's do something
  49.  
  50. GoSub("mainmenu")          ; Go to the main menu section
  51. Goto("start")              ; Call finished - reset script
  52.  
  53.  
  54. ; --------------------------
  55. :getname                   ; Get user name here
  56. Xmit("^M^J^M^JUser Name? >")
  57. PortGet(S0, 8, 60)         ; Get Name
  58.                            ; Valid User Name?
  59.                            ; NOTE: more user names could be added here
  60. CompStr(S0, "somename", "name_ok")
  61.                            ; If name is valid Goto label name_ok
  62.                            ; otherwise hangup
  63. Xmit("^M^JInvalid User Name!^M^JGoodbye!")
  64. Pause(2)
  65. Hangup()                   ; name invalid. sorry bub
  66. :name_ok
  67. Return()                   ; Go Back
  68.  
  69. ; --------------------------
  70. :getpass                   ; Get user Password here
  71. Xmit("^M^JPassword? >")
  72. LoclEcho("N")              ; Turn off Host Mode so that password
  73.                            ; won't get echoed back to user
  74. PortGet(S0, 8, 60)         ; Get Password
  75. LoclEcho("Y")              ; Turn Host Mode back on
  76.  
  77.                            ; Valid Password?
  78.                            ; NOTE: more passwords could be added here
  79. CompStr(S0, "somepass", "Pass_ok")
  80.                            ; If Password is valid Goto label name_ok
  81.                            ; otherwise hangup
  82. Xmit("^M^JInvalid Password!^M^JGoodbye!")
  83. Pause(2)
  84. Hangup()                   ; Password invalid. sorry bub
  85. :pass_ok
  86. Return()                   ; Go Back
  87.  
  88. ; --------------------------
  89. :mainmenu                  ; Main menu section
  90.  
  91.                            ; Nothing fancy here. This could be greatly expanded upon.
  92.                            ; For example a menu selection could be for F)ile List
  93.                            ; that would then upload an ASCII file containing
  94.                            ; a list of available files.
  95.  
  96. Xmit("^L")                 ; ^L clears screen
  97.  
  98.                            ; Display the Main Menu
  99.  
  100. Xmit("^M^J^M^J^M^J     Main Menu^M^J^M^J")
  101. Xmit("U)pload File^M^J")
  102. Xmit("D)ownload File^M^J")
  103. Xmit("G)oodbye^M^J")
  104. Xmit("^M^J^M^JEnter Choice >")
  105.  
  106. If("NOCARDET", "mm_exit")  ; If caller hangs up reset script
  107. PortGet(S0, 1, 60)         ; Get user's choice
  108.                            ; Compare the user choice and Goto
  109.                            ; the appropriate routine
  110. CompStr(S0, "U", "m_uload")
  111. CompStr(S0, "D", "m_dload")
  112. CompStr(S0, "G", "m_gbye")
  113.                            ; If choice is invalid inform the user
  114.                            ; and redisplay the menu
  115. Xmit("^M^J^M^J^GInvalid Response!)
  116. Pause(2)                   ; wait 2 seconds so user can see message
  117. Goto("mainmenu")           ; try again
  118.  
  119. :m_uload                   ; GoSub to the Upload Menu routine
  120. GoSub("ul_menu")
  121. Goto("mainmenu")           ; The GoSub will Return here
  122.                            ; so start main menu again
  123.  
  124. :m_dload
  125. GoSub("dl_menu")           ; GoSub to the Download Menu routine
  126. Goto("mainmenu")           ; The GoSub will Return here
  127.                            ; so start main menu again
  128.  
  129. :m_gbye                    ; User decided to leave
  130. Xmit("^M^J^M^JThanks for calling!^M^J^M^J")
  131. Pause(2)
  132.                            ; Fall through to Return()
  133.  
  134. :mm_exit                   ; Main menu exits here
  135. Return()                   ; Return back to where main menu
  136.                            ; was first called
  137.  
  138. ; --------------------------
  139. :ul_menu                   ; Upload Menu section
  140.                            ; Display the menu
  141.  
  142. Xmit("^L")                 ; ^L clears screen
  143. Xmit("^M^J^M^J     Upload Menu^M^J^M^J")
  144. Xmit("A)scii^M^J")
  145. Xmit("S)EAlink^M^J")
  146. Xmit("X)modem^M^J")
  147. Xmit("Xmodem-1(K)^M^J")
  148. Xmit("Y)modem^M^J")
  149. Xmit("Ymodem-(G)^M^J")
  150. Xmit("Ke(R)mit^M^J")
  151. Xmit("Z)modem^M^J")
  152. Xmit("Q)uit^M^J)
  153. Xmit("^M^J^M^JEnter Choice >")
  154. PortGet(S0, 1, 60)         ; Get user's protocol choice
  155. CompStr(S0, "Q", "ulquit")
  156. Xmit("^M^J^M^J")
  157. Xmit("Filename? >")
  158. PortGet(S1, 12, 60)        ; Get filename from user
  159. Xmit("^M^J^M^J")
  160.  
  161. CompStr(S1, "", "badfname") ; make sure filename isn't blank
  162. Goto("fnameok")
  163. :badfname
  164. Xmit("^M^J^M^J^GInvalid Filename!")
  165. Pause(2)
  166. Goto("ulquit")
  167.                            ; Decide which protocol to use
  168.                            ; Compare to what user entered
  169.                            ; and Goto the appropriate routine
  170. :fnameok
  171. CompStr(S0, "A", "uascii")
  172. CompStr(S0, "S", "usea")
  173. CompStr(S0, "X", "uxmodem")
  174. CompStr(S0, "K", "ukmodem")
  175. CompStr(S0, "Y", "uymodem")
  176. CompStr(S0, "G", "ugmodem")
  177. CompStr(S0, "R", "ukermit")
  178. CompStr(S0, "Z", "uzmodem")
  179. Xmit("^M^J^M^J^GInvalid protocol!")
  180. Pause(2)
  181. :ulquit
  182. Goto("ul_exit")            ; default for Quit or invalid selection
  183.  
  184.                            ; The file transfer routines are
  185.                            ; called from here
  186. :uascii
  187. RecvFile(A, S1)
  188. Goto("ul_exit")
  189.  
  190. :usea
  191. RecvFile(S, S1)
  192. Goto("ul_exit")
  193.  
  194. :uxmodem
  195. RecvFile(X, S1)
  196. Goto("ul_exit")
  197.  
  198. :ukmodem
  199. RecvFile(K, S1)
  200. Goto("ul_exit")
  201.  
  202. :uymodem
  203. RecvFile(Y, S1)
  204. Goto("ul_exit")
  205.  
  206. :ugmodem
  207. RecvFile(G, S1)
  208. Goto("ul_exit")
  209.  
  210. :ukermit
  211. RecvFile(R, S1)
  212. Goto("ul_exit")
  213.  
  214. :uzmodem
  215. RecvFile(Z, S1)
  216. Goto("ul_exit")
  217.  
  218. :ul_exit                   ; exit Upload Menu from here
  219. Return()                   ; Return to Main Menu
  220.  
  221. ; --------------------------
  222. :dl_menu                   ; Download Menu section
  223.  
  224. Xmit("^L")                 ; ^L clears screen
  225. Xmit("^M^J^M^J     Download Menu^M^J^M^J")
  226. Xmit("A)scii^M^J")
  227. Xmit("S)EAlink^M^J")
  228. Xmit("X)modem^M^J")
  229. Xmit("Xmodem-1(K)^M^J")
  230. Xmit("Y)modem^M^J")
  231. Xmit("Ymodem-(G)^M^J")
  232. Xmit("Ke(R)mit^M^J")
  233. Xmit("Z)modem^M^J")
  234. Xmit("Q)uit^M^J)
  235. Xmit("^M^J^M^JEnter Choice >")
  236. PortGet(S0, 1, 60)         ; Get user' protocol choice
  237. CompStr(S0, "Q", "dlquit")
  238. Xmit("^M^J")
  239. Xmit("^M^JFilename? >")
  240. PortGet(S1, 12, 60)        ; Get download filename
  241. Xmit("^M^J")
  242.                            ; Decide which protocol to use
  243.                            ; Compare to what user entered
  244.                            ; and Goto the appropriate routine
  245. CompStr(S0, "A", "dascii")
  246. CompStr(S0, "S", "dsea")
  247. CompStr(S0, "X", "dxmodem")
  248. CompStr(S0, "K", "dkmodem")
  249. CompStr(S0, "Y", "dymodem")
  250. CompStr(S0, "G", "dgmodem")
  251. CompStr(S0, "R", "dkermit")
  252. CompStr(S0, "Z", "dzmodem")
  253. Xmit("^M^J^M^J^GInvalid protocol!")
  254. Pause(2)
  255. :dlquit
  256. Goto("dl_exit")            ; default for Quit or invalid selection
  257.  
  258.                            ; The file transfer routines are
  259.                            ; called from here
  260. :dascii
  261. SendFile(A, S1)
  262. Goto("dl_exit")
  263.  
  264. :dsea
  265. SendFile(S, S1)
  266. Goto("dl_exit")
  267.  
  268. :dxmodem
  269. SendFile(X, S1)
  270. Goto("dl_exit")
  271.  
  272. :dkmodem
  273. SendFile(K, S1)
  274. Goto("dl_exit")
  275.  
  276. :dymodem
  277. SendFile(Y, S1)
  278. Goto("dl_exit")
  279.  
  280. :dgmodem
  281. SendFile(G, S1)
  282. Goto("dl_exit")
  283.  
  284. :dzmodem
  285. SendFile(R, S1)
  286. Goto("dl_exit")
  287.  
  288. :dzmodem
  289. SendFile(Z, S1)
  290. Goto("dl_exit")
  291.  
  292. :dl_exit                   ; exit Download Menu from here
  293. Return()                   ; Return to Main Menu
  294.  
  295. :exitscp
  296. Quit()
  297.  
  298. ; End - MCHOST.SCP